#!/usr/bin/env perl

# find a Perl module's path on the filesystem
# <https://github.com/brennen/bpb-kit/blob/master/bin/pmwhich>

use warnings;
use strict;
use 5.10.0;

my $to_use;
if (defined $ARGV[0]) {
  $to_use = $ARGV[0];
} else {
  die "Must specify a module to check path for.";
}

eval("use $to_use");

my $filename = $to_use;
$filename =~ s{ :: }{/}gx;
$filename .= '.pm';

if ($INC{$filename}) {
  say $INC{$filename};
} else {
  say "$to_use not found";
}

# say $_ . " => " . $INC{$_} for keys %INC;
